package com.syni.mdd.yhd.common.all.dao.jpa;

import com.syni.mdd.yhd.common.all.dao.BaseJPADao;
import com.syni.mdd.yhd.common.all.entity.BmsBusiness;
import com.syni.mdd.yhd.common.all.entity.BmsDxComment;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;
import java.util.Set;

public interface BmsDxCommentDao extends BaseJPADao<BmsDxComment,Integer> {

    @Query(value="select bdc.bms_video_id,count(bdc.bms_video_id) num from bms_dx_comment bdc where bdc.bms_video_id in (?1) group by bdc.bms_video_id",nativeQuery=true)
    List<Map<String,Object>> countVideoCommentNum(Set<Integer> videoIds);

    List<BmsDxComment> findByBmsVideoId(Integer videoId, Pageable pageable);

    List<BmsDxComment> findByBmsVideoIdIn(Set videoIds);

    @Query(value = "select bms_video_id from (select count(*) num ,bms_video_id,content from bms_dx_comment group by bms_video_id,content HAVING num > 1) newTable",nativeQuery = true)
    List<Map<String,Object>> findRepeatCommentVideoId();

    @Query(value = "select * from  bms_dx_comment where bms_video_id in (?1) group by bms_video_id,content ",nativeQuery = true)
    List<BmsDxComment> findVideoCommentNoRepeat(Set<Integer> videoIds);
}
